<?php

####### Account Info. ###########
$videobb_login = '';
$videobb_pass = '';
##############################

$not_done=true;
$continue_up=false;
if ($videobb_login && $videobb_pass){
	$_REQUEST['my_login'] = $videobb_login;
	$_REQUEST['my_pass'] = $videobb_pass;
	$_REQUEST['action'] = "FORM";
	echo "<b><center>Use Default login/pass.</center></b>\n";
}
if ($_REQUEST['action'] == "FORM")
    $continue_up=true;
else{
?>
<table border=0 style="width:270px;" cellspacing=0 align=center>
<form method=post>
<input type=hidden name=action value='FORM' />
<tr><td nowrap>&nbsp;User*<td>&nbsp;<input type=text name=my_login value='' style="width:160px;" />&nbsp;</tr>
<tr><td nowrap>&nbsp;Password*<td>&nbsp;<input type=password name=my_pass value='' style="width:160px;" />&nbsp;</tr>
<tr><td colspan=2 align=center><input type=submit value='Upload' /></tr>
<tr><td colspan=2 align=center><small>*You can set it as default in <b><?php echo $page_upload["videobb.com"]; ?></b></small></tr>
</table>
</form>

<?php
	}

if ($continue_up)
	{
		$not_done=false;
?>
<table width=600 align=center>
</td></tr>
<tr><td align=center>
<div id=login width=100% align=center>Login to Videobb.com</div>
<?php 
                        $rnd = time().rndNum(3);
                        $page = geturl("videobb.com", 80, "/index.php","http://videobb.com/index.php",0, 0, 0);
		        is_page($page);
                        $cookie = GetCookies($page);
                        $post = array();
		        $post['login_username'] = trim($_REQUEST['my_login']);
		        $post['login_password'] = trim($_REQUEST['my_pass']);
                        $page = geturl("videobb.com", 80, "/login.php","http://videobb.com/index.php",$cookie, $post, 0);
		        is_page($page);
                        preg_match('/^HTTP\/1\.0|1 ([0-9]+) .*/',$page,$status);
			if ($status[1] == 200) {html_error("Login error", 0);}
                        $cookie .= "; ".GetCookies($page);
                        $page = geturl("videobb.com", 80, "/index.php","http://videobb.com/index.php",$cookie, 0, 0);
		        is_page($page);
                        $page = geturl("videobb.com", 80, "/upload.php","http://videobb.com/index.php",$cookie, 0, 0);
		        is_page($page);
                        $page = geturl("videobb.com", 80, "/ajax/upload_track.php?cat_sel=1&f=$lname","http://videobb.com/upload.php\r\nX-Requested-With: XMLHttpRequest",$cookie, 0, 0);
		        is_page($page);
                        $sessionId=urlencode(cut_str ( $page ,'sessionId":"' ,'",'));
                        $sid=cut_str ( $page ,'sid":"' ,'",');
                        //$sip=cut_str ( $page ,'sip":"' ,'",');
                        //$slip=cut_str ( $page ,'slip":"' ,'",');
                        $sd=cut_str ( $page ,'sd":"' ,'",');
                        $ip=cut_str ( $page ,'ip":"' ,'",');
                        $cc=cut_str ( $page ,'cc":"' ,'",');
			$vc=cut_str ( $page ,'vc":"' ,'"');
			$enc = cut_str($page ,'enc":"' ,'",');
                        $progressURL=urldecode(cut_str ( $page ,'progressURL":"' ,'",'));
                        $submitURL=urldecode(cut_str ( $page ,'submitURL":"' ,'",'));
                        $URL = htmlspecialchars_decode($progressURL);
                        $URL=str_replace("\\","",$URL);
                        $upurl=htmlspecialchars_decode($submitURL);
			$upurl=str_replace("\\","",$upurl);

                        $page = geturl("videobb.com", 80, "/upload.php","http://videobb.com/upload.php",$cookie, 0, 0);
		        is_page($page);                                                      
?>
<script>document.getElementById('login').style.display='none';</script>
<div id=info width=100% align=center>Retrive upload ID</div>
<?php 

                        $upurl = $upurl."?X-Progress-ID=$sessionId";
			$url=parse_url($upurl);
                        unset($post);
			$post=array();
                        $post["uploadSessionId"] = $sessionId;
			$post["APC_UPLOAD_PROGRESS"] = $sessionId;
                        $post["ud"]=$ud;
			$post["un"]=$un;
			$post["enc"]=$enc;
                        $post["broadcast"]="0";
                        $post["allow_comments"]= "0";
			$post["allow_rating"]="0";
                        $post["search_by_user"]= "0";
			$post["title"]="";
                        $post["description"]="Leechviet";
                        $post["tags"] = "";
			$post["category"] = "1";
                        $post["cat_sel"]="1";
			$post["sip"]=$sip;
			$post["ps"]="1";
                        $post["cc"]=$cc;
                        $post["bsid"]= "7";
			$post["sid"]=$sid;
                        $post["ip"]= $ip;
			$post["vc"]=$vc;
                        $post["slip"]=$slip;
                        $post["sd"]="WU";
			$upfiles = upfile($url["host"], defport($url), $url["path"].($url["query"] ? "?".$url["query"] : ""), 0, $cookie, $post, $lfile, $lname, "file");
			is_page($upfiles);
?>
<script>document.getElementById('progressblock').style.display='none';</script>
<?php 	
			is_page($upfiles);
                        $upurl = $URL."/progress?X-Progress-ID=$sessionId&callback=jsonp$rnd";
                        $Url=parse_url($upurl);
                        $page = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $Url["path"].($Url["query"] ? "?".$Url["query"] : ""),"http://videobb.com/upload.php", $cookie, 0, 0, $_GET["proxy"],$pauth);
                        is_page($page);
                        $state=cut_str ( $page ,'state" : "' ,'"');
                        if($state == "starting"){
                        echo "<h3><font color='green'>File successfully uploaded to your account</font></h3>";
                        $download_link= "http://www.videobb.com/video/$vc";
                        }else {
                        html_error ('Error upload file');
                        }
	}
function rndNum($lg){
$str="0123456789"; 
for ($i=1;$i<=$lg;$i++){
$st=rand(1,9);
$pnt.=substr($str,$st,1);
}
return $pnt;
}
//VinhNhaTrang 17/12/2010
//hackinho 06/07/2011
?>
